package com.second.app.huaweiod;

/**
 * 连续3个字符出现不一样的次数
 */
public class DiffNumDemo {

    public static void main(String[] args) {

        String a = "你妈了个臭逼的狗杂碎";

        String b = "你妈了臭个奶的狗杂碎";

        int len = Math.max(a.length(), b.length());

        int count = 0;

        boolean isAllDiff = true;

        // 找出连续3个字符不一样出现的次数
        for (int i = 0; i < len - 3; i++) {
            String compareA = a.substring(i, i + 3);
            String compareB = b.substring(i, i + 3);
            for (int j = 0; j < 3;j++) {
                char aa= compareA.charAt(j);
                char bb = compareB.charAt(j);
                if (aa == bb) {
                    isAllDiff = false;
                    break;
                }
                isAllDiff = true;
            }
            if (isAllDiff) {
                count++;
            }
        }
        System.out.println("count:" + count);
    }
}
